from django.core.management.base import BaseCommand, CommandError
from faker import Faker

from realize.models.category.StationCategory import StationCategory
from realize.models.station import Station
from realize.models.FaStation import FaStation 

import random

# mock 基站数据
class Command(BaseCommand):
    help = 'Closes the specified poll for voting'

    def add_arguments(self, parser):
        parser.add_argument('number', type=int)

    def handle(self, *args, **options):
        number = options['number']
        for i in range(number):
            station = Station()
            fake = Faker()
            station.name = fake.company()
            station.location = f"{fake.latitude()}, {fake.longitude()}"
            station.address = fake.address()
            station.attach = random.choice(FaStation.objects.all())
            station.category = random.choice(StationCategory.objects.all())
            station.signal_type = random.choice(["2G", "3G", "4G"])
            station.frequency = random.randint(800, 2600)
            station.transmit_power = random.randint(10, 100)
            station.antenna_height = random.randint(10, 100)
            station.coverage_range = random.randint(1, 20)
            station.device_model = fake.company()
            station.device_status = random.choice(["Normal", "Warning", "Alarm"])
            station.alarm_status = random.choice(["Normal", "Warning", "Alarm"])
            station.save()
            self.stdout.write("ADD ----- OK")
        self.stdout.write(f"Total: {number} messages added!!!")
